package com.yuju.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yuju.common.core.dao.IBaseDao;
import com.yuju.common.core.service.AbstractBaseService;
import com.yuju.group.model.GroupParamModel;
import com.yuju.group.service.IGroupParamService;
import com.yuju.sys.dao.ISysParamDao;
import com.yuju.sys.dao.entity.SysParam;
import com.yuju.sys.model.SysParamModel;
import com.yuju.sys.service.ISysParamService;

/**
 * 
 * 类名：SysParamServiceImpl  <br />
 *
 * 功能：平台系统参数
 *
 * @author : xuehj <br />
 * @Date : 2018年2月2日 下午2:00:03  <br />
 * @version : 1.1 <br />
 */
@Service
public class SysParamServiceImpl extends AbstractBaseService<SysParamModel, SysParam, String> implements ISysParamService{
	@Autowired
	private ISysParamDao sysParamDao;
	@Autowired
	private IGroupParamService groupParamService;
	
	@Override
	public IBaseDao<SysParamModel, SysParam, String> getDao() {
		// TODO Auto-generated method stub
		return sysParamDao;
	}
	
	/**
	 * 
	 * 功能：添加集团后的操作<br/>
	 *
	 * @author zhousc
	 * @Date 2018年1月5日 上午8:57:16 <br/>
	 */
	@Override
	public int saveGroupAfter(String groupId){
		//首先根据条件查询出需要添加的参数信息
		SysParamModel sysParamModel = new SysParamModel();
		sysParamModel.setReadonly((byte)1);
		sysParamModel.setLevel((byte)1);
		List<SysParamModel> list = this.getDao().list(getBeanMap(sysParamModel));
		//将查出的数据对应添加到grp_param表中
		for (int i = 0; i < list.size(); i++) {
			GroupParamModel groupParamModel = new GroupParamModel();
			groupParamModel.setCode(list.get(i).getCode());
			groupParamModel.setName(list.get(i).getName());
			groupParamModel.setValue(list.get(i).getValue());
			groupParamModel.setGroupId(groupId);
			groupParamService.save(groupParamModel);
		}
		return 1;
	}
	
}
